package com.zkk.dao.impl;

import com.zkk.dao.ManagerDao;
import com.zkk.pojo.Manager;
import com.zkk.utils.DruidUtil;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.List;

public class ManagerDaoImpl implements ManagerDao {
    private JdbcTemplate jdbcTemplate=new JdbcTemplate(DruidUtil.getDataSource());
    @Override
    public Manager login(Manager manager) {
        List<Manager> query = jdbcTemplate.query("select * from manager", new BeanPropertyRowMapper<>(Manager.class));
        for (Manager manager1 : query) {
            if(manager1.getUsername().equals(manager.getUsername()) && manager1.getPassword().equals(manager.getPassword())){
                return manager;
            }

        }
        return null;
    }
}
